#========================================================================
#
# Goo library Makefile
#
# Copyright 1996-2003 Glyph & Cog, LLC
#
#========================================================================

# includes basic building rules
# REL_ADDR has to be defined, because Makefile.rules refers 
# to the Makefile.flags
REL_ADDR = ../../../
include $(REL_ADDR)/Makefile.rules

CFLAGS   += $(EXTRA_XPDF_CFLAGS)
CXXFLAGS += $(EXTRA_XPDF_CXXFLAGS)

CXX_SRC = \
	GHash.cc \
	GList.cc \
	GString.cc \
	gmem.cc \
	gmempp.cc \
	gfile.cc \
	FixedPoint.cc

C_SRC = \
	parseargs.c
HEADERS = \
	FixedPoint.h\
	GHash.h\
	GList.h\
	GMutex.h\
	GString.h\
	gfile.h\
	gmem.h\
	gtypes.h\
	parseargs.h\
	vms_dirent.h\
	vms_sys_dirent.h\
	vms_unix_time.h

#------------------------------------------------------------------------

TARGET = $(LIBPREFIX)Goo.a
all: $(TARGET)

staticlib: $(TARGET)
#------------------------------------------------------------------------

GOO_CXX_OBJS = GHash.o GList.o GString.o gmem.o gmempp.o gfile.o FixedPoint.o
GOO_C_OBJS = parseargs.o
GOO_OBJS = $(GOO_CXX_OBJS) $(GOO_C_OBJS)

$(TARGET): deps_cxx deps_c $(GOO_OBJS)
	$(DEL_FILE) $(TARGET)
	$(AR) $(TARGET) $(GOO_OBJS)
	$(RANLIB) $(TARGET)

.PHONY: install-dev uninstall-dev
install-dev: staticlib $(DEV_CONFIG)
	$(MKDIR) $(INSTALL_ROOT)$(INCLUDE_PATH)/goo
	$(COPY_FILE) $(HEADERS) $(INSTALL_ROOT)$(INCLUDE_PATH)/goo
	$(MKDIR) $(INSTALL_ROOT)$(LIB_PATH)/goo
	$(COPY_FILE) $(TARGET) $(INSTALL_ROOT)$(LIB_PATH)/goo

uninstall-dev:
	cd $(INSTALL_ROOT)$(INCLUDE_PATH)/goo && $(DEL_FILE) $(HEADERS)
	$(DEL_DIR)  $(INSTALL_ROOT)$(INCLUDE_PATH)/goo/
	cd $(INSTALL_ROOT)$(LIB_PATH)/goo && $(DEL_FILE) $(TARGET)
	$(DEL_DIR)  $(INSTALL_ROOT)$(LIB_PATH)/goo/

#------------------------------------------------------------------------

clean:
	$(DEL_FILE) $(GOO_OBJS) $(TARGET) deps_cxx deps_c

#------------------------------------------------------------------------

deps_cxx: $(HEADERS)
	$(CXX) $(MANDATORY_INCPATH) -M -MF deps_cxx $(CXX_SRC)

deps_c: $(HEADERS)
	$(CC) $(MANDATORY_INCPATH) -M -MF deps_c $(C_SRC)

# This requires GNU make (or compatible) because deps file doesn't
# exist in time when invoked for the first time and thus has to
# be generated
include deps_cxx
include deps_c
